import requests
import argparse
import sys

RED = "\033[91m"
GREEN = "\033[92m"
YELLOW = "\033[93m"
BLUE = "\033[94m"
RESET = "\033[0m"

def banner():
    print(f"{BLUE}[*] Apache Tomcat CVE-2025-24813 Scanner {RESET}")

def check_vulnerability(target):
    url = f"{target}/test.jsp"
    headers = {"Content-Type": "application/x-www-form-urlencoded"}
    data = "This is a test file"

    try:
        response = requests.request("PUT", url, headers=headers, data=data, timeout=5)
        if response.status_code in [200, 201, 204]:
            print(f"{GREEN}[+] Target is vulnerable to CVE-2025-24813! {RESET}")
        else:
            print(f"{RED}[-] Target is not vulnerable.{RESET}")
    except requests.exceptions.RequestException:
        print(f"{YELLOW}[!] Failed to connect to target.{RESET}")

def main():
    banner()
    parser = argparse.ArgumentParser(description="Apache Tomcat CVE-2025-24813 Vulnerability Scanner")
    parser.add_argument("target", help="Target URL (e.g., http://192.168.1.1:8080)")
    args = parser.parse_args()

    print(f"{BLUE}[*] Scanning {args.target}...{RESET}")
    check_vulnerability(args.target)

if __name__ == "__main__":
    main()

